<template>
    <div class="big">
        <!-- 导航栏 -->
        <!-- <van-sticky> -->
        <div class="navigation">
            <div class="icon" @click="back">
                <img src="../../assets/home-img/返回.png" alt="">
            </div>
            <h2 class="title">妙手医生网络诊室</h2>
            <div class="icon">
                <img src="../../assets/home-img/分享.png" alt="">
            </div>
        </div>
        <!-- </van-sticky> -->
        <!-- 个人信息 -->
        <header>
            <div class="headerTop">
                <!-- 头像 -->
                <div class="left">
                    <img :src="detailItem.avatar" alt="" class="user">
                </div>
                <!-- 资料 -->
                <div class="right">
                    <div class="name">
                        <h3 class="username">
                            {{ detailItem.name }}
                            <span class="rating" v-if="detailItem.optimum === true">三甲</span>
                        </h3>
                        <!-- <button v-show="detailItem.state === false" class="attention" @click="interest">{{detailItem.state == false?'+关注': '已关注'}}</button> -->
                        <button v-show="detailItem.state === false" class="attention" @click="interest">+关注</button>
                        <button v-show="detailItem.state === true" class="attention attentioned"
                            @click="interest">已关注</button>
                    </div>
                    <!-- 职务 -->
                    <div class="position"> {{ detailItem.position }} <span class="separate">|</span> {{
                        detailItem.class }} </div>
                    <!-- 医院 -->
                    <div class="hospital"> {{ detailItem.hospital }} </div>
                </div>
            </div>
            <!-- 浏览人次 -->
            <div class="headerMiddle">
                <div>
                    <div class="bigNum">{{ detailItem.browse }}</div>
                    <div>浏览人次</div>
                </div>
                <div>
                    <div class="bigNum">{{ detailItem.praise }}%</div>
                    <div>好评率</div>
                </div>
                <div>
                    <div class="bigNum">{{ detailItem.reply }}分钟</div>
                    <div>平均响应</div>
                </div>
                <div>
                    <div class="bigNum">{{ detailItem.fans }}</div>
                    <div>粉丝数</div>
                </div>
            </div>
            <!-- 擅长 -->
            <div class="headerBottom">
                <div class="van-multi-ellipsis--l2">
                    擅长:&emsp;{{ detailItem.strong }}
                </div>
            </div>
            <!-- 查看简介 -->
            <div class="underside">
                <button class="all">查看简介 > </button>
            </div>
        </header>
        <!-- 医生服务 -->
        <main>
            <h1 class="service">医生服务</h1>
            <div class="doctorServices">
                <div class="serviceItem" @click="showPopup">
                    <img src="../../assets/home-img/c1_06.png" alt="">
                    <p class="serviceTitle">在线咨询</p>
                    <p class="serviceTitle1">1对1问医生</p>
                </div>
                <div class="serviceItem">
                    <img src="../../assets/home-img/c2_03.png" alt="">
                    <p class="serviceTitle">复诊开方</p>
                    <p class="serviceTitle1">申请用药</p>
                </div>
                <div class="serviceItem">
                    <img src="../../assets/home-img/c2_05.png" alt="">
                    <p class="serviceTitle">优选药房</p>
                    <p class="serviceTitle1">用心优选</p>
                </div>
                <div class="serviceItem">
                    <img src="../../assets/home-img/c1_03.png" alt="">
                    <p class="serviceTitle">门诊预约</p>
                    <p class="serviceTitle1">预约线下就诊</p>
                </div>
            </div>
        </main>
        <!-- 评论 -->
        <footer>
            <div class="footerTop">
                <span class="evaluate">评价</span>
                <span class="number">({{ evaluateList.length }})</span>
                <span class="more" @click="toCommentMore">查看更多> </span>
            </div>
            <div class="footerMiddle">
                <div class="middleItem" v-for="(item, index) in evaluateList" :key="index">
                    <div class="userEvaluate">
                        <span>福建漳州{{ item.pub }}评价了图文咨询</span>
                        <van-rate class="starRating" v-model="item.star" :size="25" color="#ec6a0c" void-icon="star"
                            void-color="#eee" />
                    </div>
                    <div class="advantage">
                        <button>回答很及时</button>
                        <button>讲解细致耐心</button>
                        <button>态度很好</button>
                        <button>回答很专业</button>
                    </div>
                    <div class="thank">
                        <span>感谢{{ item.content }}医生的回复~</span>
                    </div>
                    <div class="time">
                        <span>2021-06-25 {{ item.time }}</span>
                    </div>
                </div>
            </div>
        </footer>
        <!-- 锦旗 -->
        <div class="banner">
            <div class="bannerTop">
                <span class="evaluate">锦旗</span>
                <span class="number">({{ bannerList.length }})</span>
                <span class="more">查看更多> </span>
            </div>
            <div class="bannerMiddle">
                <div class="bannerItem" v-for="(item, index) in bannerList" :key="index">
                    <p>{{ item.city }}{{ item.pub }}赠送了{{ item.title }}</p>
                    <span style="color: #b4b4b6;">2024/12/20 {{ item.time }}</span>
                    <div class="img">
                        <img src="../../assets/home-img/锦旗.png" alt="">
                    </div>
                </div>
                <div class="deliver">
                    <span @click="toThankYou">
                        <img src="../../assets/home-img/锦旗icon.png" alt="">
                        我要送锦旗 >
                    </span>
                </div>
            </div>
        </div>
        <!-- 底部 -->
        <div class="bottom">
            <button class="send" @click="showPopup">发消息</button>
            <!-- 底部弹出层 -->
            <van-popup v-model:show="showBottom" position="bottom" :style="{ height: '60%' }">
                <div class="type">
                    <p class="consultTitle">选择咨询类型 <span @click="close">×</span> </p>
                    <div class="tyleMiddle">
                        <div class="typeItem">
                            <div class="typefirs">
                                <img src="../../assets/home-img/咨询1_03.png" alt="">
                            </div>
                            <div class="second">
                                <span>图文咨询</span>
                                <p class="introduce">和医生发文字, 图片聊天</p>
                                <p class="Service">
                                    服务时长:&ensp;20条消息, 有效期:&ensp;24小时
                                </p>
                            </div>
                            <div class="third">
                                <span class="price">¥60.00/次</span>
                                <button @click="toConsultDetail">咨询</button>
                            </div>
                        </div>
                        <div class="typeItem">
                            <div class="typefirs">
                                <img src="../../assets/home-img/咨询1_06.png" alt="">
                            </div>
                            <div class="second">
                                <span>图文咨询</span>
                                <p class="introduce">和医生发文字, 图片聊天</p>
                                <p class="Service">
                                    服务时长:&ensp;10分钟, 有效期:&ensp;24小时
                                </p>
                            </div>
                            <div class="third">
                                <span class="price">¥60.00/次</span>
                                <button @click="toConsultDetail">咨询</button>
                            </div>
                        </div>
                        <div class="typeItem">
                            <div class="typefirs">
                                <img src="../../assets/home-img/咨询1_03.png" alt="">
                            </div>
                            <div class="second">
                                <span>图文咨询</span>
                                <p class="introduce">和医生发文字, 图片聊天</p>
                                <p class="Service">
                                    服务时长:&ensp;15分钟, 有效期:&ensp;24小时
                                </p>
                            </div>
                            <div class="third">
                                <span class="price">¥60.00/次</span>
                                <button @click="toConsultDetail">咨询</button>
                            </div>
                        </div>
                    </div>
                </div>
            </van-popup>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router";
import http from '../../http/http'

const type = ref('');
const route = useRoute();
const router = useRouter();
const detail = JSON.parse(JSON.stringify(route.query));
const detailItem = ref([]);

// 评价数据
const evaluateList = ref([]);
const getEvaluateList = async () => {
    await http.get('/comment').then(res => {
        evaluateList.value = res.data.data;
    })
}

// 获取医生详情
const getDetail = async () => {
    await http.get(`/doctorList?id=${detail.id}`).then(res => {
        detailItem.value = res.data.data;
    })
}

// 底部弹窗
const showBottom = ref(false);
const showPopup = () => {
    showBottom.value = true;
};

// 关闭弹窗
const close = () => {
    showBottom.value = false;
}

// 关注
const interest = async () => {
    await http.get(`/collect?id=${detail.id}`).then(res => {
        getDetail()
    })
}

// 返回
const back = () => {
    // router.push('/home');
    router.back();
}

// 锦旗数据
const bannerList = ref([]);
const getBannerList = async () => {
    await http.get('/banner').then(res => {
        bannerList.value = res.data.data;
    })
}

// 跳转到答谢医生
// const toThankYou = () => {
//     console.log(detail.id);
//     router.push({ path: '/thankYou', query: { id: detail.id } });
//     // router.push('/thankYou');
// }

// 跳转到咨询详情页面
const toConsultDetail = () => {
    router.push({ path: '/consultDetail', query: { id: detail.id } });
}

// 评价更多页面
const toCommentMore = () => {
    router.push({ path: '/commentMore', query: { id: detail.id } });
}

onMounted(() => {
    getDetail();
    getEvaluateList()
    getBannerList()
})

</script>

<style lang="scss" scoped>
* {
    margin: 0;
    padding: 0;
}

.big {
    width: 100%;
    // height: 1334px;
    height: 100lvh;
    overflow: scroll;
    background-image: linear-gradient(#1e6fff 20%, #f6f6f6 30%);
    padding-left: 20px;
    padding-right: 20px;
    overflow: scroll;
    -ms-overflow-style: none;

    &::-webkit-scrollbar {
        display: none;
    }


    .navigation {
        width: 100%;
        height: 90px;
        // line-height: 90px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background-color: #1e6fff;

        .icon {
            img {
                width: 55px;
                height: 55px;
                border-radius: 27.5px;
            }
        }

        .title {
            font-size: 45px;
            color: #fff;
        }
    }

    header {
        width: 710px;
        height: 580px;
        margin-top: 60px;
        background-color: #fff;
        border-radius: 25px;

        .headerTop {
            width: 710px;
            height: 232px;
            display: flex;
            justify-content: space-between;
            // background-color: pink;

            .left {
                width: 225px;
                height: 232px;
                display: flex;
                align-items: center;
                justify-content: center;

                .user {
                    width: 170px;
                    height: 170px;
                    border-radius: 85px;
                }
            }

            .right {
                width: 525px;
                height: 232px;
                // background-color: blue;
                padding-top: 25px;
                position: relative;

                .name {
                    width: 497px;
                    height: 60px;
                    line-height: 60px;

                    .username {
                        font-size: 40px;
                        display: flex;
                        align-items: center;
                        font-weight: 550;
                        letter-spacing: 2px;

                        .rating {
                            font-size: 24px;
                            color: #fff;
                            background-color: #00ba82;
                            font-weight: 400;
                            display: inline-block;
                            width: 70px;
                            height: 40px;
                            text-align: center;
                            line-height: 40px;
                            border-radius: 7px;
                        }
                    }

                    .attention {
                        position: absolute;
                        right: 30px;
                        top: 20px;
                        width: 160px;
                        height: 66px;
                        line-height: 66px;
                        text-align: center;
                        font-size: 30px;
                        color: #f57007;
                        background-color: #fdf1e3;
                        border-radius: 33px;
                        border: 0;
                        font-weight: bold;
                    }

                    .attentioned {
                        position: absolute;
                        right: 30px;
                        top: 20px;
                        width: 160px;
                        height: 66px;
                        line-height: 66px;
                        text-align: center;
                        font-size: 30px;
                        color: #fff;
                        background-color: #ccc;
                        border-radius: 33px;
                        border: 0;
                        font-weight: bold;
                    }
                }

                .position {
                    width: 497px;
                    margin-top: 10px;
                    font-size: 30px;
                    color: #4f4d50;
                    letter-spacing: 2px;

                    .separate {
                        margin: 0 10px;
                        color: #ccc;
                    }
                }

                .hospital {
                    margin-top: 10px;
                    font-size: 30px;
                    color: #4f4d50;
                    letter-spacing: 2px;
                }
            }
        }

        .headerMiddle {
            margin-top: 20px;
            width: 710px;
            height: 100px;
            background-color: #fff;
            // background-color: pink;
            display: flex;
            justify-content: space-around;
            align-items: center;
            font-size: 28px;
            color: #b0b0b0;

            .bigNum {
                text-align: center;
                font-size: 40px;
                color: black;
                margin-bottom: 5px;
                font-weight: bold;
            }
        }

        .headerBottom {
            width: 710px;
            line-height: 50px;
            background-color: #fff;
            padding: 0 20px;
            margin-top: 20px;
            font-size: 32px;
            color: #484649;
        }

        .underside {
            width: 710px;
            height: 90px;
            padding-top: 15px;

            .all {
                height: 60px;
                float: right;
                margin-right: 20px;
                font-size: 36px;
                border: 0;
                background-color: #fff;
                color: #4d68af;
            }
        }
    }

    main {
        width: 710px;
        height: 365px;
        margin-top: 20px;
        background-color: #fff;
        border-radius: 15px;
        padding-left: 20px;
        padding-right: 20px;
        padding-top: 20px;

        .service {
            width: 670px;
            font-size: 40px;
            height: 55px;
            line-height: 55px;
        }

        .doctorServices {
            width: 670px;
            margin-top: 50px;
            display: flex;
            justify-content: space-between;
            text-align: center;

            .serviceTitle {
                margin-top: 10px;
                font-size: 34px;
                font-weight: bold;
            }

            .serviceTitle1 {
                margin-top: 10px;
                font-size: 25px;
                color: #b3b3b3;
            }
        }
    }

    footer {
        width: 100%;
        height: 800px;
        margin-top: 20px;
        background-color: #fff;
        border-radius: 15px;
        padding: 0 20px;
        overflow: hidden;

        .footerTop {
            width: 95%;
            margin: 0 auto;
            height: 90px;
            font-size: 40px;
            display: flex;
            align-items: center;
            justify-content: space-around;

            .evaluate {
                font-weight: bold;
                // margin-left: 20px;
            }

            .number {
                width: 58%;
                font-size: 34px;
                color: #5d5d5f;
            }

            .more {
                font-size: 36px;
                color: #4d68af;
                // margin-right: 20px;
            }
        }

        .footerMiddle {
            width: 95%;
            height: 640px;
            margin: 0 auto;
            margin-top: 10px;
            overflow: scroll;

            .middleItem {
                width: 100%;
                margin-bottom: 10px;
                border-bottom: 1px solid #f6f6f8;

                .userEvaluate {
                    width: 100%;
                    display: flex;
                    justify-content: space-between;
                    color: #555555;
                }

                .advantage {
                    width: 100%;
                    margin-top: 10px;

                    button {
                        padding: 10px 20px;
                        margin: 5px 15px;
                        margin-left: 0;
                        border-radius: 27.5px;
                        border: 1.5px solid #e8e8e8;
                        background-color: #fff;
                    }
                }

                .thank {
                    font-size: 30px;
                }

                .time {
                    margin-top: 25px;
                    color: #bcbbb9;
                    margin-bottom: 20px;
                }
            }
        }

        .footerBottom {
            width: 100%;
            height: 100px;
            display: flex;
            align-items: center;
            justify-content: center;

            button {
                font-size: 30px;
                border: 0;
                background-color: #fff;
            }
        }
    }

    .banner {
        width: 100%;
        height: 800px;
        margin-top: 20px;
        border-radius: 20px;
        background-color: #fff;
        padding: 0 20px;
        margin-bottom: 120px;

        .bannerTop {
            width: 95%;
            margin: 0 auto;
            height: 90px;
            font-size: 40px;
            display: flex;
            align-items: center;
            justify-content: space-around;

            .evaluate {
                font-weight: bold;
                // margin-left: 20px;
            }

            .number {
                width: 58%;
                font-size: 34px;
                color: #5d5d5f;
            }

            .more {
                font-size: 36px;
                color: #4d68af;
                // margin-right: 20px;
            }
        }

        .bannerMiddle {
            width: 100%;
            height: 100%;
            overflow: scroll;

            .bannerItem {
                width: 100%;
                height: 590px;

                .img {
                    width: 100%;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                }
            }

            .deliver {
                width: 100%;
                display: flex;
                align-items: center;
                justify-content: center;
                margin-bottom: 120px;
                color: #4a63b7;

                img {
                    width: 20px;
                    height: 20px;
                }
            }
        }


    }
}

.bottom {
    width: 100%;
    height: 120px;
    position: fixed;
    bottom: 0;
    left: 0;
    background-color: #fff;
    display: flex;
    align-items: center;

    .send {
        width: 93%;
        height: 80px;
        margin: 0 auto;
        background-color: #1e6fff;
        border: 0;
        border-radius: 15px;
        font-size: 30px;
        font-weight: bold;
        color: #fff;
    }

    .type {
        width: 100%;
        height: 100%;
        padding: 0 10px;

        .consultTitle {
            width: 100%;
            height: 100px;
            line-height: 100px;
            font-size: 35px;
            font-weight: bold;

            span {
                float: right;
                font-weight: normal;
                font-size: 65px;
                margin-right: 10px;
                color: #686868;
            }
        }

        .tyleMiddle {
            width: 100%;
            height: 100%;

            .typeItem {
                width: 100%;
                height: 185px;
                display: flex;
                justify-content: space-around;
                margin-bottom: 20px;
                background-color: #fafbfd;
                border-radius: 15px;
                padding: 15px;

                .second {
                    width: 55%;

                    span {
                        font-size: 35px;
                        font-weight: bold;
                        line-height: 50px;
                    }

                    .introduce {
                        margin: 5px 0;
                        color: #818183;
                    }

                    .Service {
                        color: #818183;
                    }
                }

                .third {
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    padding-top: 10px;

                    .price {
                        font-size: 30px;
                        color: #ff5f11;
                    }

                    button {
                        padding: 10px 25px;
                        border: 0;
                        background-color: #206afd;
                        color: #fff;
                        border-radius: 10px;
                    }
                }
            }
        }
    }
}
</style>